package com.neusoft.movie.v_movies.activity;

import android.content.Context;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.neusoft.movie.v_movies.R;
import com.neusoft.movie.v_movies.common.Constants;
import com.neusoft.movie.v_movies.javabean.WordsBean;
import com.neusoft.movie.v_movies.listener.RetrofitListener;
import com.neusoft.movie.v_movies.model.WordsModel;
import com.squareup.picasso.Picasso;
import static com.neusoft.movie.v_movies.common.Constants.PHOTO_URL;

public class DayWordActivity extends BaseActivity implements RetrofitListener {

    private TextView w_name,w_info;
    private ImageView w_pic,left;
    private Context mContext;
    @Override
    void initViews() {
        setLayout(R.layout.activity_day_word);
        w_name = (TextView) findViewById(R.id.w_name);
        w_pic = (ImageView) findViewById(R.id.w_pic);
        w_info = (TextView) findViewById(R.id.w_info);

        left=(ImageView) findViewById(R.id.left_button);

    }

    @Override
    void initData() {
        words();

    }
   void words()
    {
        WordsModel wordsModel = new WordsModel();
        wordsModel.words(this);
    }




    @Override
    void initEvents() {
        left.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

    }

    @Override
    public void onSuccess(Object o, int flag) {
        switch(flag){
            case Constants.WORDS:
                WordsBean wordsBean=(WordsBean) o;
                String pic = PHOTO_URL+wordsBean.getW_pic();
                if(!wordsBean.getW_pic().equals("")){
                    Picasso.with(mContext).load(pic).into(w_pic);
                }
                w_name.setText(wordsBean.getW_name());
                w_info.setText(wordsBean.getW_info());

                break;


        }
    }

    @Override
    public void onFailed() {
        Toast.makeText(DayWordActivity.this,"失败",Toast.LENGTH_LONG).show();
    }
}
